package com.example.wanghao.wangyixinwen.home;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

import com.example.wanghao.wangyixinwen.R;
import com.example.wanghao.wangyixinwen.act.MainActivity;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;

/**
 * Created by wanghao on 2016/5/18.
 */
public abstract class BasePage {

    public boolean isLoad = false;//用来记录当前界面是否已经获取了数据,true为已经获取
    private View mView;
    public Context mContext;
    public TextView mTxt_title;//用来展示标题的文本控件,有子类来设置
    public SlidingMenu mSlidingMenu;
    public ImageButton mBtn_right;//标题栏最右边的图表按钮

    public BasePage(Context context) {
        this.mContext = context;
        mView = initView();
        mSlidingMenu = ((MainActivity) mContext).getSlidingMenu();

    }

    public View getRootView() {

        return mView;
    }

    public abstract View initView();

    public abstract void initData();

    //设置标题头目的一些页面展示
    public void initTitleBar(View view) {
        Button btn_left = (Button) view.findViewById(R.id.btn_left);
        btn_left.setVisibility(View.GONE);
        ImageButton imgbtn_left = (ImageButton) view.findViewById(R.id.imgbtn_left);
//        imgbtn_left.setBackgroundResource(R.drawable.img_menu);
        imgbtn_left.setImageResource(R.drawable.img_menu);
        imgbtn_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mSlidingMenu.toggle();
            }
        });

        mTxt_title = (TextView) view.findViewById(R.id.txt_title);

        ImageButton imgbtn_right = (ImageButton) view.findViewById(R.id.imgbtn_right);
        imgbtn_right.setVisibility(View.GONE);

        mBtn_right = (ImageButton) view.findViewById(R.id.btn_right);


    }


    public void onResume() {
    }

}
